<template>
  <el-card :class="{ panelBg: isPanelStyle }">
    <div class="personal-message-box">
      <el-avatar :size="70" :src="userInfo.avatar"></el-avatar>
      <span class="user-title">{{ userInfo.realName }}</span>
      <div class="btn-box">
        <span
          @click.stop="exitEdit"
          v-show="isPanelStyle"
          :class="{ exitBtn: isPanelStyle }"
          >退出编辑</span
        >
        <span class="person-btn" v-show="!isPanelStyle">
          <router-link to="/info/index">{{ $t('navbar.userinfo') }}</router-link>
        </span>
        <span @click.stop="editDesktop" v-show="!isPanelStyle" class="edit-btn"
          ><i style="margin-right: 5px;" class="iconfont icon-edit"></i
          >管理我的桌面
        </span>
      </div>
    </div>
  </el-card>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
  props: ['id', 'editPersonStyle'],
  data () {
    return {
      panelId: this.id,
      isPanelStyle: this.editPersonStyle
    }
  },
  computed: {
    ...mapGetters(['website', 'userInfo', 'orgTree', 'permission']),
  },
  methods: {
    // 删除面板项发送事件
    deletePanelItem () {
      this.$emit('deletePanelItemEvent', this.panelId)
    },
    // 跳转管理界面事件
    editDesktop () {
      this.$emit('editDesktopEvent', 'edit')
    },
    exitEdit () {
      this.$emit('editDesktopEvent','view')
    }
  }
}
</script>

<style>
.el-card {
  height: 100%;
}
.personal-message-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
  height: 100%;
}
.personal-message-box .user-title {
  margin: 20px 0;
  font-size: 1.5em;
  font-weight: bold;
}
.btn-box {
  display: flex;
  justify-content: center;
  width: 100%;
}
.btn-box .person-btn,
.edit-btn {
  flex: 0 0 50%;
  border: 1px solid #d7ddeb;
  border-radius: 4px;
  padding: 10px 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9em;
}
.btn-box .person-btn {
  margin-right: 5px;
}
.btn-box .edit-btn {
  margin-left: 5px;
}
.panelBg {
  background-color: #d3d6dc !important;
  border: none !important;
}
.exitBtn {
  border: 1px solid #d7ddeb;
  border-radius: 4px;
  text-align: center;
  padding: 10px 50px;
  cursor: pointer;
  background-color: #fff;
}
</style>
